#include "CUpgradeState.h"
#include "CGame.h"
#include "CGamePlayState.h"
#include "CWeapon.h"
#include "CUpgradeSystem.h"
#include "SGD Wrappers/CSGD_DirectInput.h"

CUpgradeState* CUpgradeState::GetInstance( void )
{
	static CUpgradeState upstate;
	return &upstate;
}
void CUpgradeState::Enter(void)
{
	CUpgradeSystem::GetInstance()->InitUpgradeSystem();
	m_Player.SetPlayerCombos();
}
bool CUpgradeState::Input(void)
{
	if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_SPACE ) )
	{
		SwitchTabs();
	}
	if( m_fSlowTimer >= 0.00f )
	{
		if( CSGD_DirectInput::GetInstance()->KeyDown( DIK_UP ) )
		{
			m_fSlowTimer = 0.0f;

			if( m_bTab == false )
			{
#if 1
				if( m_nIndex == 0 )
				{
					if( m_Player.GetSwordLevel() == CUpgradeSystem::GetInstance()->GetConditions()[ m_Player.GetSwordLevel() + 5 ]->m_nLevelNeeded )
					{
						if( m_Player.GetPlayerExp() > 0 && m_Player.GetSwordLevel() != 3 )
						{
							m_Player.SetSwordExp( m_Player.GetSwordExp() + 10 );
							m_Player.SetPlayerExp( m_Player.GetPlayerExp() - 10 );
							if( m_Player.GetPlayerExp() <= 0 )
								m_Player.SetPlayerExp( 0 );
						}
						if( m_Player.GetSwordExp() == CUpgradeSystem::GetInstance()->GetConditions()[ m_Player.GetSwordLevel() + 5 ]->m_nXPNeeded )
						{		
							m_Player.SetSwordExp( 0 );
							if( m_Player.GetSwordLevel() != 3 )
								m_Player.SetSwordLevel( m_Player.GetSwordLevel() + 1 );
							//else
							//{
							//	if( m_Player.GetSwordLevel() == 3 && m_Player.GetSword() )
							//	{
							//		m_Player.SetSwordLevel( 4 );
							//	}
							//}
						}
						if( m_Player.GetSwordExp() == CUpgradeSystem::GetInstance()->GetConditions()[ 8 ]->m_nXPNeeded )
						{
							m_Player.SetSwordExp( CUpgradeSystem::GetInstance()->GetConditions()[ 8 ]->m_nXPNeeded );
						}

					}
				}
				else if( m_nIndex == 1 )
				{
					if( m_Player.GetSpearLevel() == CUpgradeSystem::GetInstance()->GetConditions()[ m_Player.GetSpearLevel() + 2 ]->m_nLevelNeeded )
					{
						if( m_Player.GetPlayerExp() > 0 && m_Player.GetSpearLevel() != 3 )
						{
							m_Player.SetSpearExp( m_Player.GetSpearExp() + 10 );
							m_Player.SetPlayerExp( m_Player.GetPlayerExp() - 10 );
							if( m_Player.GetPlayerExp() <= 0 )
								m_Player.SetPlayerExp( 0 );
						}
						if( m_Player.GetSpearExp() == CUpgradeSystem::GetInstance()->GetConditions()[ m_Player.GetSpearLevel() + 2 ]->m_nXPNeeded )
						{		
							m_Player.SetSpearExp( 0 );
							if( m_Player.GetSpearLevel() != 3 )
								m_Player.SetSpearLevel( m_Player.GetSpearLevel() + 1 );
							//else
							//{
							//	if( m_Player.GetSpearLevel() == 3 && m_Player.GetSpear() )
							//	{
							//		m_Player.SetSpearLevel( 4 );
							//	}
							//}
						}

					}
				}
				else if( m_nIndex == 2 )
				{

					if( m_Player.GetGauntletLevel() == CUpgradeSystem::GetInstance()->GetConditions()[ m_Player.GetGauntletLevel() - 1 ]->m_nLevelNeeded )
					{
						if( m_Player.GetPlayerExp() > 0 && m_Player.GetGauntletLevel() != 3 )
						{
							m_Player.SetGauntletExp( m_Player.GetGauntletExp() + 10 );
							m_Player.SetPlayerExp( m_Player.GetPlayerExp() - 10 );
							if( m_Player.GetPlayerExp() <= 0 )
								m_Player.SetPlayerExp( 0 );
						}
						if( m_Player.GetGauntletExp() == CUpgradeSystem::GetInstance()->GetConditions()[ m_Player.GetGauntletLevel() - 1 ]->m_nXPNeeded )
						{		
							m_Player.SetGauntletExp( 0 ); //m_Player.GetGauntletExp() - CUpgradeSystem::GetInstance()->GetConditions()[ m_Player.GetGauntletLevel() - 1 ]->m_nXPNeeded );
							if( m_Player.GetGauntletLevel() != 3 )
								m_Player.SetGauntletLevel( m_Player.GetGauntletLevel() + 1 );
							//else
							//{
							//	if( m_Player.GetGauntletLevel() == 3 && m_Player.GetGauntlet() )
							//	{
							//		m_Player.SetGauntletLevel( 4 );
							//	}
							//}
						}
					}
				}
				else if( m_nIndex == 3 )
				{
					if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_RETURN ) )
					{
						CGame::GetInstance()->ChangeState( CGamePlayState::GetInstance() );
					}
				}
#endif
			}
			if( m_bTab == true )
			{
#if 1
				if( m_nIndex == 0 )
				{
					if( m_Player.GetSwordLevel() >= CUpgradeSystem::GetInstance()->GetConditions()[ m_nSwordComboIndex + 9 ]->m_nLevelNeeded )
					{
						if( m_bSwordCombo[ m_nSwordComboIndex ] != true )
						{
							if( m_Player.GetPlayerExp() > 0  )
							{
								m_Player.SetSwordComboExp( m_Player.GetSwordComboExp() + 10 );
								m_Player.SetPlayerExp( m_Player.GetPlayerExp() - 10 );
								if( m_Player.GetPlayerExp() <= 0 )
									m_Player.SetPlayerExp( 0 );
							}
							if( m_Player.GetSwordComboExp() == CUpgradeSystem::GetInstance()->GetConditions()[ m_nSwordComboIndex + 9 ]->m_nXPNeeded )
							{		
								m_bSwordCombo[ m_nSwordComboIndex ] = true;
								m_nSwordComboIndex++;
								m_Player.SetSwordComboExp( 0 ); 
								if( m_Player.GetCombos()[ m_Player.GetSwordLevel() + 3 ]->GetIsActive() == false )
									m_Player.GetCombos()[ m_Player.GetSwordLevel() + 3 ]->SetIsActive( true );
							}
						}
					}
				}
#endif
#if 1
				else if( m_nIndex == 1 )
				{
					if( m_Player.GetSpearLevel() >= CUpgradeSystem::GetInstance()->GetConditions()[ m_nSpearComboIndex + 13 ]->m_nLevelNeeded )
					{
						if( m_bSpearCombo[ m_nSpearComboIndex ] != true )
							if( m_Player.GetPlayerExp() > 0  )
							{
								m_Player.SetSpearComboExp( m_Player.GetSpearComboExp() + 10 );
								m_Player.SetPlayerExp( m_Player.GetPlayerExp() - 10 );
								if( m_Player.GetPlayerExp() <= 0 )
									m_Player.SetPlayerExp( 0 );
							}
							if( m_Player.GetSpearComboExp() >= CUpgradeSystem::GetInstance()->GetConditions()[ m_nSpearComboIndex + 13 ]->m_nXPNeeded )
							{		
								m_bSpearCombo[ m_nSpearComboIndex ] = true;
								m_nSpearComboIndex++;
								m_Player.SetSpearComboExp( 0 ); 
								if( m_Player.GetCombos()[ m_Player.GetSpearLevel() + 7 ]->GetIsActive() == false )
									m_Player.GetCombos()[ m_Player.GetSpearLevel() + 7 ]->SetIsActive( true );
							}
					}
				}
#endif
#if 1
				else if( m_nIndex == 2 )
				{
					if( m_Player.GetGauntletLevel() >= CUpgradeSystem::GetInstance()->GetConditions()[ m_nGauntletComboIndex + 17 ]->m_nLevelNeeded )
					{
						if( m_bGauntletCombo[ m_nGauntletComboIndex ] != true )
							if( m_Player.GetPlayerExp() > 0  )
							{
								m_Player.SetGauntletComboExp( m_Player.GetGauntletComboExp() + 10 );
								m_Player.SetPlayerExp( m_Player.GetPlayerExp() - 10 );
								if( m_Player.GetPlayerExp() <= 0 )
									m_Player.SetPlayerExp( 0 );
							}
							if( m_Player.GetGauntletComboExp() >= CUpgradeSystem::GetInstance()->GetConditions()[ m_nGauntletComboIndex + 17 ]->m_nXPNeeded )
							{		
								m_bGauntletCombo[ m_nGauntletComboIndex ] = true;
								m_nGauntletComboIndex++;
								m_Player.SetGauntletComboExp( 0 ); 
								if( m_Player.GetCombos()[ m_Player.GetGauntletLevel() - 1 ]->GetIsActive() == false )
									m_Player.GetCombos()[ m_Player.GetGauntletLevel() - 1 ]->SetIsActive( true );
							}
					}
				}
				else if( m_nIndex == 3 )
				{
					if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_RETURN ) )
					{
						CGame::GetInstance()->ChangeState( CGamePlayState::GetInstance() );
					}
				}
#endif
			}
		}
	}
	if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_DOWN ) )
	{

	}
	if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_LEFT ) )
	{
		m_nIndex--;
		if( m_nIndex < 0 )
			m_nIndex = 3;
	}
	if( CSGD_DirectInput::GetInstance()->KeyPressed( DIK_RIGHT ) )
	{
		m_nIndex++;
		if( m_nIndex > 3 )
			m_nIndex = 0;
	}

	return false;
}
void CUpgradeState::Update(float fElapsedTime)
{
	m_fSlowTimer += fElapsedTime;
}
void CUpgradeState::Render(void)
{

	if( m_bTab == false )
	{
#if 1
		char GauntletLevelBuffer[ 20 ] = { 0 };
		char SwordLevelBuffer[ 20 ] = { 0 };
		char SpearLevelBuffer[ 20 ] = { 0 };
		char GauntletBuffer[ 20 ] = { 0 };
		char SpearBuffer[ 20 ] = { 0 };
		char SwordBuffer[ 20 ] = { 0 };

		CSGD_Direct3D::GetInstance()->Clear( 0,0,0 ) ;
		CSGD_Direct3D::GetInstance()->DeviceBegin();
		CSGD_Direct3D::GetInstance()->SpriteBegin();

		m_pBMFonts.Draw("FORGE OF STICKS", CGame::GetInstance()->GetScreenWidth()/2 - 200, CGame::GetInstance()->GetScreenHeight() /2 - 150, 3.0f, D3DXCOLOR(255, 255, 255, 255));
		CSGD_TextureManager::GetInstance()->Draw(CSGD_TextureManager::GetInstance()->LoadTexture("resources/graphics/weapons.bmp"), 100, 150, 0.5f, 0.5f);

		RECT temprect = {0,0,640,480};
		CSGD_TextureManager::GetInstance()->Draw(CSGD_TextureManager::GetInstance()->LoadTexture("resources/graphics/AnG_pauseoverlay.png"),
			0,0, 1.0f, 1.0f, &temprect, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(100,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(CSGD_TextureManager::GetInstance()->LoadTexture("Resources/Graphics/SGD_MenuCursor.png", D3DCOLOR_XRGB(255, 255, 255))
			, 80 +( 100 * m_nIndex), 400);
		m_pBMFonts.Draw("SWORD",100,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("SPEAR",200,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("GAUNTLET",300,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("EXIT",400,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("PRESS SPACE TO GO TO COMBOS",100,450,1.0f,D3DXCOLOR( 255,255,255,255 ) );

		CSGD_Direct3D::GetInstance()->SpriteEnd();
		char buffer[ 30 ] = { 0 };
		sprintf_s( buffer , "Player Exp: %d " , m_Player.GetPlayerExp() );
		CSGD_Direct3D::GetInstance()->DrawText( buffer, 450,400);

		sprintf_s(SwordLevelBuffer, "Level: %d",m_Player.GetSwordLevel() );
		CSGD_Direct3D::GetInstance()->DrawText( SwordLevelBuffer, 100, 300 );

		sprintf_s(SpearLevelBuffer, "Level: %d",m_Player.GetSpearLevel() );
		CSGD_Direct3D::GetInstance()->DrawText( SpearLevelBuffer, 200, 300 );

		sprintf_s(GauntletLevelBuffer, "Level: %d",m_Player.GetGauntletLevel() );
		CSGD_Direct3D::GetInstance()->DrawText( GauntletLevelBuffer, 300, 300 );

		sprintf_s( SwordBuffer, " %d  /  %d " , m_Player.GetSwordExp(), m_Player.GetWeapon()[ m_Player.SearchWeapon("Sword")  ]->GetExpToNextLevel() );
		CSGD_Direct3D::GetInstance()->DrawText( SwordBuffer, 100, 350 );

		sprintf_s( SpearBuffer, " %d   /   %d ",m_Player.GetSpearExp(),m_Player.GetWeapon()[ m_Player.SearchWeapon("Spear") ]->GetExpToNextLevel() );
		CSGD_Direct3D::GetInstance()->DrawText( SpearBuffer, 200, 350 );

		sprintf_s( GauntletBuffer, " %d   /   %d ",m_Player.GetGauntletExp(),m_Player.GetWeapon()[ m_Player.SearchWeapon("Gauntlet") ]->GetExpToNextLevel() );
		CSGD_Direct3D::GetInstance()->DrawText( GauntletBuffer, 300, 350 );

		CSGD_Direct3D::GetInstance()->DeviceEnd();
		CSGD_Direct3D::GetInstance()->Present();
#endif
	}
	if( m_bTab == true )
	{
#if 1
		CSGD_Direct3D::GetInstance()->Clear( 0,0,0 ) ;
		CSGD_Direct3D::GetInstance()->DeviceBegin();
		CSGD_Direct3D::GetInstance()->SpriteBegin();

		RECT temprect = {0,0,640,480};
		CSGD_TextureManager::GetInstance()->Draw(CSGD_TextureManager::GetInstance()->LoadTexture("resources/graphics/AnG_pauseoverlay.png"),
			0,0, 1.0f, 1.0f, &temprect, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(100,255,255,255));
		CSGD_TextureManager::GetInstance()->Draw(CSGD_TextureManager::GetInstance()->LoadTexture("Resources/Graphics/SGD_MenuCursor.png", D3DCOLOR_XRGB(255, 255, 255))
			, 80 +( 100 * m_nIndex), 400);
		m_pBMFonts.Draw("SWORD",100,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("SPEAR",200,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("GAUNTLET",300,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("EXIT",400,400,1.0f, D3DXCOLOR( 255,255,255,255 ) );
		m_pBMFonts.Draw("PRESS SPACE TO GO TO WEAPONS",100,450,1.0f,D3DXCOLOR( 255,255,255,255 ) );

		CSGD_Direct3D::GetInstance()->SpriteEnd();
		char buffer[ 30 ] = { 0 };
		sprintf_s( buffer , "Player Exp: %d " , m_Player.GetPlayerExp() );
		CSGD_Direct3D::GetInstance()->DrawText( buffer, 450,400);
		if( m_nIndex == 0 )
		{
			char SwordComboBuffer1[ 40 ] = { 0 };
			char SwordComboBuffer2[ 40 ] = { 0 };
			char SwordComboBuffer3[ 40 ] = { 0 };
			char SwordComboBuffer4[ 40 ] = { 0 };
#if 1
			if( m_Player.GetSwordLevel() >= 1 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( SwordComboBuffer1," %s \t\t %s ", m_Player.GetCombos()[ 4 ]->GetComboName().c_str(), m_Player.GetCombos()[ 4 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer1, 100, 50 );
				if( m_bSwordCombo[ 0 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 9 ]->m_nXPNeeded, CUpgradeSystem::GetInstance()->GetConditions()[ 9 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 50 ); 
				}
				else if( m_bSwordCombo[ 0 ] == false && m_bSwordCombo[ 1 ] == false && m_bSwordCombo[ 2 ] == false && m_bSwordCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetSwordComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 9 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 50 ); 
				}
			}
			else
			{
				sprintf_s( SwordComboBuffer1," %s \t ?????", m_Player.GetCombos()[ 4 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer1, 100, 50 );
			}
#endif
#if 1
			if( m_Player.GetSwordLevel() >= 2 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( SwordComboBuffer2," %s \t\t %s ", m_Player.GetCombos()[ 5 ]->GetComboName().c_str(), m_Player.GetCombos()[ 5 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer2, 100, 150 );
				if( m_bSwordCombo[ 1 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 10 ]->m_nXPNeeded,
						CUpgradeSystem::GetInstance()->GetConditions()[ 10 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 150 ); 
				}
				if( m_bSwordCombo[ 0 ] == true && m_bSwordCombo[ 1 ] == false && m_bSwordCombo[ 2 ] == false && m_bSwordCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetSwordComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 10 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 150 ); 
				}
			}
			else
			{
				sprintf_s( SwordComboBuffer2," %s \t ?????", m_Player.GetCombos()[ 5 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer2, 100, 150 );
			}
#endif
#if 1
			if( m_Player.GetSwordLevel() >= 3 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( SwordComboBuffer3," %s \t\t %s ", m_Player.GetCombos()[ 6 ]->GetComboName().c_str(), 
					m_Player.GetCombos()[ 6 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer3, 100, 250 );
				if( m_bSwordCombo[ 2 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 11 ]->m_nXPNeeded,
						CUpgradeSystem::GetInstance()->GetConditions()[ 11 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 250 ); 
				}
				if( m_bSwordCombo[ 0 ] == true && m_bSwordCombo[ 1 ] == true && m_bSwordCombo[ 2 ] == false && m_bSwordCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetSwordComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 11 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 250 ); 
				}
			}
			else
			{
				sprintf_s( SwordComboBuffer3," %s \t ?????", m_Player.GetCombos()[ 6 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer3, 100, 250 );
			}
#endif
			if( m_Player.GetSwordLevel() == 4  )
			{
				sprintf_s( SwordComboBuffer4," %s \t %s ", m_Player.GetCombos()[ 7 ]->GetComboName().c_str(), m_Player.GetCombos()[ 7 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer4, 100, 350 );
			}
			else
			{
				sprintf_s( SwordComboBuffer4," %s \t ????? ", m_Player.GetCombos()[ 7 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SwordComboBuffer4, 100, 350 );
			}
		}
		if( m_nIndex == 1 )
		{
			char SpearComboBuffer1[ 40 ] = { 0 };
			char SpearComboBuffer2[ 40 ] = { 0 };
			char SpearComboBuffer3[ 40 ] = { 0 };
			char SpearComboBuffer4[ 40 ] = { 0 };
			if( m_Player.GetSpearLevel() >= 1 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( SpearComboBuffer1," %s \t\t %s ", m_Player.GetCombos()[ 8 ]->GetComboName().c_str(), m_Player.GetCombos()[ 8 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer1, 100, 50 );
				if( m_bSpearCombo[ 0 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 13 ]->m_nXPNeeded, 
						CUpgradeSystem::GetInstance()->GetConditions()[ 13 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 50 ); 
				}
				else if( m_bSpearCombo[ 0 ] == false && m_bSpearCombo[ 1 ] == false && m_bSpearCombo[ 2 ] == false && m_bSpearCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetSpearComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 13 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 50 ); 
				}
			}
			else
			{
				sprintf_s( SpearComboBuffer1," %s \t ?????", m_Player.GetCombos()[ 8 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer1, 100, 50 );
			}

			if( m_Player.GetSpearLevel() >= 2 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( SpearComboBuffer2," %s \t\t %s ", m_Player.GetCombos()[ 9 ]->GetComboName().c_str(), m_Player.GetCombos()[ 9 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer2, 100, 150 );
				if( m_bSpearCombo[ 1 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 14 ]->m_nXPNeeded,
						CUpgradeSystem::GetInstance()->GetConditions()[ 14 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 150 ); 
				}
				else if( m_bSpearCombo[ 0 ] == true && m_bSpearCombo[ 1 ] == false && m_bSpearCombo[ 2 ] == false && m_bSpearCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetSpearComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 14 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 150 ); 
				}
			}
			else
			{
				sprintf_s( SpearComboBuffer2," %s \t ?????", m_Player.GetCombos()[ 9 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer2, 100, 150 );
			}
			if( m_Player.GetSpearLevel() >= 3 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( SpearComboBuffer3," %s \t\t %s ", m_Player.GetCombos()[ 10 ]->GetComboName().c_str(), 
					m_Player.GetCombos()[ 10 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer3, 100, 250 );
				if( m_bSpearCombo[ 2 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 15 ]->m_nXPNeeded,
						CUpgradeSystem::GetInstance()->GetConditions()[ 15 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 250 ); 
				}
				else if( m_bSpearCombo[ 0 ] == true && m_bSpearCombo[ 1 ] == true && m_bSpearCombo[ 2 ] == false && m_bSpearCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetSpearComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 15 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 250 ); 
				}
			}
			else
			{
				sprintf_s( SpearComboBuffer3," %s \t ?????", m_Player.GetCombos()[ 10 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer3, 100, 250 );
			}
			if( m_Player.GetSpearLevel() == 4  )
			{
				sprintf_s( SpearComboBuffer4," %s \t %s ", m_Player.GetCombos()[ 11 ]->GetComboName().c_str(), m_Player.GetCombos()[ 11 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer4, 100, 350 );
			}
			else
			{
				sprintf_s( SpearComboBuffer4," %s \t ????? ", m_Player.GetCombos()[ 11 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( SpearComboBuffer4, 100, 350 );
			}
		}
		if( m_nIndex == 2 )
		{
			char GauntletComboBuffer1[ 40 ] = { 0 };
			char GauntletComboBuffer2[ 40 ] = { 0 };
			char GauntletComboBuffer3[ 40 ] = { 0 };
			char GauntletComboBuffer4[ 40 ] = { 0 };
			if( m_Player.GetGauntletLevel() >= 1 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( GauntletComboBuffer1," %s \t\t %s ", m_Player.GetCombos()[ 0 ]->GetComboName().c_str(), m_Player.GetCombos()[ 0 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer1, 100, 50 );
				if( m_bGauntletCombo[ 0 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 9 ]->m_nXPNeeded, 
						CUpgradeSystem::GetInstance()->GetConditions()[ 9 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 50 ); 
				}
				else if( m_bGauntletCombo[ 0 ] == false && m_bGauntletCombo[ 1 ] == false && m_bGauntletCombo[ 2 ] == false && m_bGauntletCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetGauntletComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 9 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 50 ); 
				}
			}
			else
			{
				sprintf_s( GauntletComboBuffer1," %s \t ?????", m_Player.GetCombos()[ 0 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer1, 100, 50 );
			}

			if( m_Player.GetGauntletLevel() >= 2 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( GauntletComboBuffer2," %s \t\t %s ", m_Player.GetCombos()[ 1 ]->GetComboName().c_str(), 
					m_Player.GetCombos()[ 1 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer2, 100, 150 );
				if( m_bGauntletCombo[ 1 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 10 ]->m_nXPNeeded,
						CUpgradeSystem::GetInstance()->GetConditions()[ 10 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 150 ); 
				}
				else if( m_bGauntletCombo[ 0 ] == true && m_bGauntletCombo[ 1 ] == false && m_bGauntletCombo[ 2 ] == false && m_bGauntletCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetGauntletComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 10 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 150 ); 
				}
			}
			else
			{
				sprintf_s( GauntletComboBuffer2," %s \t ?????", m_Player.GetCombos()[ 1 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer2, 100, 150 );
			}
			if( m_Player.GetGauntletLevel() >= 3 )
			{
				char ComboBufferExp[ 20 ] = { 0 };
				sprintf_s( GauntletComboBuffer3," %s \t\t %s ", m_Player.GetCombos()[ 2 ]->GetComboName().c_str(), 
					m_Player.GetCombos()[ 2 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer3, 100, 250 );
				if( m_bGauntletCombo[ 2 ] == true )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ",CUpgradeSystem::GetInstance()->GetConditions()[ 11 ]->m_nXPNeeded,
						CUpgradeSystem::GetInstance()->GetConditions()[ 11 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 250 ); 
				}
				else if( m_bGauntletCombo[ 0 ] == true && m_bGauntletCombo[ 1 ] == true && m_bGauntletCombo[ 2 ] == false && m_bGauntletCombo[ 3 ] == false )
				{
					sprintf_s( ComboBufferExp," %d  \t / \t  %d ", m_Player.GetGauntletComboExp(), CUpgradeSystem::GetInstance()->GetConditions()[ 11 ]->m_nXPNeeded );
					CSGD_Direct3D::GetInstance()->DrawText( ComboBufferExp, 300, 250 ); 
				}
			}
			else
			{
				sprintf_s( GauntletComboBuffer3," %s \t ?????", m_Player.GetCombos()[ 2 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer3, 100, 250 );
			}
			if( m_Player.GetGauntletLevel() == 4  )
			{
				sprintf_s( GauntletComboBuffer4," %s \t %s ", m_Player.GetCombos()[ 3 ]->GetComboName().c_str(), m_Player.GetCombos()[ 3 ]->GetComboButtons().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer4, 100, 350 );
			}
			else
			{
				sprintf_s( GauntletComboBuffer4," %s \t ????? ", m_Player.GetCombos()[ 3 ]->GetComboName().c_str() );
				CSGD_Direct3D::GetInstance()->DrawText( GauntletComboBuffer4, 100, 350 );
			}
#endif	
		}

		CSGD_Direct3D::GetInstance()->DeviceEnd();
		CSGD_Direct3D::GetInstance()->Present();	
	}

}
void CUpgradeState::Exit(void)
{
	CGame::GetInstance()->ChangeState( CGamePlayState::GetInstance() );
}
void CUpgradeState::SwitchTabs( void )
{
	m_nIndex = 0;
	m_bTab = !m_bTab;
}
